<?php

/*

View Mail (mail_view.php)

*/

$page_title = "View Mail";
$rank_check = 3;
include "header.inc.php";

print "$openHTML";

$findMail = fetch("SELECT * FROM mail_topics2 WHERE to_user = '$userid' AND id = '$id' AND game = '$game'");
$findMail2 = fetch("SELECT * FROM mail_messages2 WHERE mail_id = '$findMail[id]' AND game = '$game'");
$findSender = fetch("SELECT username,display_name,premium,display_prem FROM members2 WHERE id = '$findMail[from_user]' AND game = '$game'");
$findMail2[message] = badwords(smilies(strip_tags("$findMail2[message]", "<b><i><u>")));

if (($findSender[premium] == 1) AND ($findSender[display_prem]))
{
	$findSender[display_name] = $findSender[display_prem];

	if ($findMail2[colors])
	{
		$explodeColors = explode(", ", $findMail2[colors]);
		if ($explodeColors[1])
		{
			$bgColor = " BGCOLOR=\"$explodeColors[1]\"";
		}
	}
}

if (!$explodeColors[0]) { $explodeColors[0] = "#000000"; }
$findMail2[message] = format($findMail2[message],"$explodeColors[0]");

mysql_query("UPDATE mail_topics2 SET status = '1' WHERE to_user = '$userid' AND id = '$id' AND game = '$game'");

$sent_date = date("H:i, M j",$findMail[timestamp]);

ECHO <<<END

<CENTER>

<P><TABLE BGCOLOR="#000000" CELLSPACING=0 CELLPADDING=0 WIDTH=475>
   <TR>
      <TD BGCOLOR="$topAndBottomBG">
         <CENTER><IMG SRC="omegapets/images/newdesign/reading_message.gif" WIDTH=475 HEIGHT=14 ALIGN=bottom></CENTER>
      </TD>
   </TR>
</TABLE>
<TABLE BGCOLOR="#000000" CELLSPACING=1 CELLPADDING=0 WIDTH=475>
   <TR BGCOLOR="#FFFFFF">
      <TD WIDTH=120 HEIGHT=25>
         <P><B>&nbsp;Subject:</B></P>
      </TD>
      <TD HEIGHT=25>
         <P>&nbsp;&nbsp;$findMail[subject]</P>
      </TD>
   </TR>
   <TR BGCOLOR="$reallyLight">
      <TD WIDTH=120 HEIGHT=25>
         <P><B>&nbsp;From:</B></P>
      </TD>
      <TD HEIGHT=25>
         <P>&nbsp;&nbsp;<a href=user_profile.php?game=$game&user=$findSender[username]>$findSender[display_name]</a> <font size=-1>&#91;<a href=buds.php?game=$game&bud=$findSender[username]>Add Buddy</a> | <a href=block_user.php?game=$game&id=$findSender[username]>Block User</a>&#93;</font>
      </TD>
   </TR>
   <TR BGCOLOR="#FFFFFF">
      <TD WIDTH=120>
         <CENTER><BR>
         <TABLE BGCOLOR="#3399FF" CELLSPACING=1 CELLPADDING=0 WIDTH=80>
            <TR>
               <TD WIDTH=80 HEIGHT=15 BGCOLOR="#99CCFF">
                  <CENTER><A HREF="mail_send.php?game=$game&type=reply&id=$id"><FONT SIZE="-1" COLOR="#000066">Reply</FONT></A></CENTER>
               </TD>
            </TR>
         </TABLE>

         <P><TABLE BGCOLOR="#FF6666" CELLSPACING=1 CELLPADDING=0 WIDTH=80>
            <TR>
               <TD WIDTH=80 HEIGHT=15 BGCOLOR="#FFCCCC">
                  <CENTER><A HREF="mail_delete.pro.php?game=$game&id=$id"><FONT SIZE="-1" COLOR="#990000">Delete</FONT></A></CENTER>
               </TD>
            </TR>
         </TABLE>
         </P>

         <P><TABLE BGCOLOR="#66FF66" CELLSPACING=1 CELLPADDING=0 WIDTH=80>
            <TR>
               <TD WIDTH=80 HEIGHT=15 BGCOLOR="#CCFFCC">
                  <CENTER><A HREF="mail_send.php?game=$game&type=forward&id=$id"><FONT SIZE="-1" COLOR="#006600">Forward</FONT></A></CENTER>
               </TD>
            </TR>
         </TABLE>
         </P>

         <P><TABLE BGCOLOR="#FF6633" CELLSPACING=1 CELLPADDING=0 WIDTH=80>
            <TR>
               <TD WIDTH=80 HEIGHT=15 BGCOLOR="#FFCC99">
                  <CENTER><A HREF="mail.php?game=$game"><FONT SIZE="-1" COLOR="#CC3300">Inbox</FONT></A></CENTER>
               </TD>
            </TR>
         </TABLE>
         </P></CENTER>
      </TD>
      <TD VALIGN=top>
         <P><TABLE CELLSPACING=8 CELLPADDING=0>
            <TR>
               <TD$bgColor>

                  $findMail2[message]

                  <p><font size=-1>Sent at $sent_date</font></p>
               </TD>
            </TR>
         </TABLE>
         </P>
      </TD>
   </TR>
</TABLE>
</P></CENTER>

END;

print "$closeHTML";
?>